#include "stdafx.h"
#include "Vector.h"
#include "Point.h"
#include <math.h>

using namespace aiRobots;

Point::Point()
{
	this->X = 0;
	this->Y = 0;
	this->Z = 0;
}

Point::Point(ptype x, ptype y, ptype z)
{
	this->X = x;
	this->Y = y;
	this->Z = z;
}

void Point::Print()
{
	cout << "X: " << (ptype)((int)(this->X*10000)) / 10000 << ", ";
	cout << "Y: " << (ptype)((int)(this->Y*10000)) / 10000 << ", ";
	cout << "Z: " << (ptype)((int)(this->Z*10000)) / 10000 << endl;
}

Point Point::operator=(const Point &p)
{
	this->X = p.X;
	this->Y = p.Y;
	this->Z = p.Z;
	return *this;
}

Point Point::operator+(const Point &p)
{
	Point result(this->X, this->Y, this->Z);
	result.X = result.X + p.X;
	result.Y = result.Y + p.Y;
	result.Z = result.Z + p.Z;
	return result;
}

Point Point::operator-(const Point &p)
{
	Point result(this->X, this->Y, this->Z);
	result.X = result.X - p.X;
	result.Y = result.Y - p.Y;
	result.Z = result.Z - p.Z;
	return result;
}

Point Point::operator*(ptype a)
{
	Point result(this->X, this->Y, this->Z);
	result.X = result.X * a;
	result.Y = result.Y * a;
	result.Z = result.Z * a;
	return result;
}

Point Point::operator/(ptype a)
{
	Point result(this->X, this->Y, this->Z);
	if(a!=0)
	{
		result.X = result.X / a;
		result.Y = result.Y / a;
		result.Z = result.Z / a;
	}
	return result;
}

Point Point::operator=(Vector &v)
{
	vtype temp[VSIZE] = {0};
	v.GetValue(&temp[0]);
	this->X = temp[0];
	this->Y = temp[1];
	this->Z = temp[2];
	return *this;
}

Point Point::operator=(Matrix &m)
{
	mtype temp[MSIZE] = {0};
	m.GetValue(&temp[0]);
	this->X = temp[0];
	this->Y = temp[1];
	this->Z = temp[2];
	return *this;
}